home *** CD-ROM | disk | FTP | other *** search
- /*
- * dayd.c
- *
- * DayTime server for the Macintosh. Modeled after my Dayd program for UNIX.
- * This program also verifies whether my ip library will work under the printf
- * system.
- *
- */
-
- /* Additional Mac Includes */
- #include <MacTCPCommonTypes.h>
-
- /* Ansi Includes */
- #include <stdio.h>
- #include <time.h>
-
- /* Additional Includes */
- #define DAYD
- #include "globals.h"
- #include "ip.h"
-
-
- int daytimed (short sock);
- void InitToolBox(void);
-
- main()
- {
- short msock;
-
- InitToolBox();
-
- //printf("Dyad server for MetroWerks text environment\n");
- if (InitMacTCP() != noErr) {
- SysBeep(3);
- //printf("InitMacTCP() failed!\n");
- return;
- }
-
- msock = socket (IPPROTO_TDP);
- if (msock < 0) {
- //printf("socket() failure!\n");
- return;
- }
-
- if ((bind(msock, 1026) ) < 0) {
- // printf("bind() failure!\n");
- return;
- }
-
- if ((accept (msock)) < 0) {
- //printf("accept failed: %s\n",gErrno);
- goto foo;
- }
- //printf("msock accepted\n");
- (void) daytimed(msock);
-
- foo:
- (void) mac_close (msock);
- // printf("closed stream\n");
- }
-
-
- void InitToolBox(void)
- {
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitCursor();
-
- /* if (InitMacTCP() != noErr) {
- SysBeep(3);
- ExitToShell();
- }*/
- }
-
- int daytimed(short sock)
- {
- time_t tim;
-
- (void) time(&tim);
- (void) mac_write(sock, ctime(&tim), sizeof (time_t));
- return 0;
- }
-
-
- /*int daytimed(int sock)
- {
- DateTimeRec date;
- char time[40];
- char day[4];
- char month[13];
-
- GetTime(&date);
- SetDayAndMonth(date, day, month);
- }*/
-
- /*void SetDayAndMonth(DateTimeRec date, char *day, char *month)
- {
- switch (date.month) {
- 1:
- strcpy(day, "Jan");*/